﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyModels
{
    /// <summary>
    /// 通用返回消息类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class MessageModel<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int status { get; set; } = 200;

        /// <summary>
        /// 返回信息
        /// </summary>
        public string message { get; set; } = "";

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool success { get; set; } = false;

        /// <summary>
        /// 返回数据
        /// </summary>
        public T? data { get; set; }

        /// <summary>
        /// 开发者信息
        /// </summary>
        public string msgDev { get; set; }

        public static MessageModel<T>Success(string msg)
        {
            return Message(true, msg, default);
        }

        public static MessageModel<T>Success(string msg,T data)
        {
            return Message(true, msg, data);
        }

        public static MessageModel<T> Fail(string msg)
        {
            return Message(false, msg, default);
        }

        public static MessageModel<T>Fail(string msg,T data)
        {
            return Message(false , msg, data);
        }
        /// <summary>
        /// 返回消息
        /// </summary>
        /// <param name="success">失败/成功</param>
        /// <param name="msg">消息</param>
        /// <param name="response">数据</param>
        /// <returns></returns>
        public static MessageModel<T>Message(bool success, string msg,T response)
        {
            return new MessageModel<T> { message = msg, success = success, data = response };
        }
    }
    public class MessageModel
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Status { get; set; } = 200;

        /// <summary>
        /// 返回信息
        /// </summary>
        public string Message { get; set; } = "";

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool  Success { get; set; }=false;

        /// <summary>
        /// 返回数据
        /// </summary>
        public object? Data { get; set; }
    }
}
